<template>
	<view class="container">
		<cu-list-cell :list="menuList" :menuArrow="true" @action="handleRoute"></cu-list-cell>
		<!-- 	<view class="padding flex flex-direction bg-white"><button class="cu-btn  line-red lg"
			@click="handleLogoOut">退出登录</button></view> -->
	</view>
</template>

<script setup lang="ts">
	import cuListCell from '@/components/cu-list-cell.vue';
	import {
		useSettingStore
	} from '@/stores/index';
	import {
		logout
	} from '@/common/api/login';
	const setting = useSettingStore();
	const menuList = [{
		cuIcon: 'newsfill',
		color: 'purple',
		badge: 0,
		name: '修改密码',
		path: '/views/login/updatepwd'
	},
	{
		cuIcon: 'friend',
		color: 'blank',
		badge: 22,
		name: '意见反馈',
		path: '/views/other/feedback'
	}, {
		cuIcon: 'friend',
		color: 'blank',
		badge: 22,
		name: '清除缓存',
		path: 'clear'
	},{
		cuIcon: 'friend',
		color: 'blank',
		badge: 22,
		name: '平台管理',
		path: 'login'
	},
	{
		cuIcon: 'profile',
		color: 'blank',
		badge: 0,
		name: '用户协议',
		path: '/views/other/agreement'
	},
	{
		cuIcon: 'community',
		color: 'blank',
		badge: 0,
		name: '隐私协议',
		path: '/views/other/agreementprivacy'
	},
	{
		cuIcon: 'question',
		color: 'blank',
		badge: 0,
		name: '关于我们',
		path: '/views/other/aboutus'
	}
	];
	/**
	 * 点击事件
	 */
	const handleRoute = (e : any) => {
		if (e.currentTarget.dataset.value.path == "clear") {
			try {
				uni.clearStorage()
				uni.clearStorageSync()
				handleLogoOut()
			} catch (e) {
				//TODO handle the exception
			}
			return;
		}
		if (e.currentTarget.dataset.value.path == "login") {
			uni.navigateTo({
				url: "/pages/other/phonelogin"
			});
			return;
		}
		uni.navigateTo({
			url: e.currentTarget.dataset.value.path
		});
	};
	/**
	 * 点击事件
	 */
	const handleLogoOut = () => {
		setting.logout();
		setting.housing = {
			"id": 0,
			"communityId": 0,
			"name": "",
			"imgUrl": "",
			"dictIds": "",
			"region": "",
			"address": "",
			"remark": "",
			"latitude": 0,
			"longitude": 0
		}
		setting.community = {
			address: "",
			createTime: "",
			description: "",
			dictIds: null,
			id: 0,
			latitude: "",
			longitude: "",
			name: "",
			region: "",
			remark: ""
		}
		//logout();
		uni.reLaunch({
			url: '/pages/index/index'
		});
	};
</script>

<style></style>